package com.quzitech.efest.utils;

import android.util.Log;

import com.quzitech.efest.protocol.StringUtil;
import com.quzitech.efest.protocol.ResponseCmd.IRESTYPE;
import com.quzitech.efest.view.BatteryAmount;

public class SetBatteryParmUtil {

	public static void set(String msg, BatteryAmount ba) {

		switch (Integer.parseInt(String.valueOf(StringUtil.getLocatedString(
				IRESTYPE.ResCH, msg).charAt(3)))) {
		case 1:
			ba.setAd_v(Integer.parseInt(
					StringUtil.getLocatedString(IRESTYPE.ResCH, msg).substring(
							4, 8), 16));
			ba.setAd_i(Integer.parseInt(
					StringUtil.getLocatedString(IRESTYPE.ResCH, msg).substring(
							8, 12), 16));
			ba.setI_mode(Integer.parseInt(String.valueOf(StringUtil
					.getLocatedString(IRESTYPE.ResCH, msg).charAt(13))));
			ba.setMode((Integer.parseInt(String.valueOf(StringUtil
					.getLocatedString(IRESTYPE.ResCH, msg).charAt(15)))));
			Log.v("reponse",
					ba.getSlotno() + "---------------->" + "Ad_v()----"
							+ ba.getAd_v() + "\n" + "Ad_i()---" + ba.getAd_i()
							+ "\n" + "I_mode()--" + ba.getI_mode() + "\n"
							+ " Mode()---" + ba.getMode() + "\n");
			break;
		case 2:
			ba.setTime_s((Integer.parseInt(
					StringUtil.getLocatedString(IRESTYPE.ResCH, msg).substring(
							4, 8), 16)));
			ba.setCap((Integer.parseInt(
					StringUtil.getLocatedString(IRESTYPE.ResCH, msg).substring(
							8, 12), 16)));
			ba.setType((Integer.parseInt(String.valueOf(StringUtil
					.getLocatedString(IRESTYPE.ResCH, msg).charAt(13)))));
			ba.setPercent(((Integer.parseInt(
					String.valueOf(StringUtil.getLocatedString(IRESTYPE.ResCH,
							msg).substring(14, 16)), 16))));
			Log.v("reponse", ba.getSlotno() + "---------------->"
					+ "Time_s()----" + ba.getTime_s() + "\n" + "getCap()---"
					+ ba.getCap() + "\n" + "Type()--" + ba.getType() + "\n"
					+ " Percent()---" + ba.getPercent() + "\n");
			break;
		default:
			break;
		}
	}
}
